package yunquan.wang.modules.base.web;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import yunquan.wang.base.service.BaseService;
import yunquan.wang.base.web.BaseController;
import yunquan.wang.modules.base.entity.UserBasic;
import yunquan.wang.modules.base.service.RolesinfoService;
import yunquan.wang.modules.base.service.UserBasicService;

 
@Controller
@RequestMapping("/core/userbasic")
public class UserBasicController extends BaseController<UserBasic>{
	@Resource
	private UserBasicService userBasicService;
	@Resource
	private RolesinfoService rolesinfoService;
 
	@RequestMapping(value = "/list.do")
	public ModelAndView list() {
		return baseList();
	}
 
	@RequestMapping(value = "/save.do")
	public ModelAndView save(HttpServletRequest request,
			@Valid UserBasic entity, BindingResult bindingResult, String [] rolesIds) {
		entity = userBasicService.save(entity, rolesIds);
		ModelAndView mv = new ModelAndView("redirect:list.do");
		return mv;
	}

 
	@RequestMapping(value = "/view.do")
	public ModelAndView view(String id) {
		return baseView();
	}

 
	@RequestMapping(value = "/input.do")
	public ModelAndView input(String id) {
		ModelAndView mv =  baseInput();
		mv.addObject("allRoles", rolesinfoService.findAll());
		return mv;
	}
 
	@RequestMapping(value = "/delete.do")
	public  
	ModelAndView delete(String id) {
		return baseDelete();
	}

	@Override
	public BaseService<UserBasic> getService() {
		return userBasicService;
	}
}
